package com.leapp.sk.util

import java.util.regex.Pattern

/**
 * 数字工具类
 * @author  chaohaipeng  on 2018/7/17.
 */
class NumberUtil {
    companion object {
        /**
         * 判断是否是纯数字
         */
        fun isNumber(number: String): Boolean {
            val pattern = Pattern.compile("[0-9]{1,}")
            val matcher = pattern.matcher(number as CharSequence)
            val result = matcher.matches()
            return result
        }

        /**
         * 字符串转换纯数字
         */
        fun  transNumber(number: String): Int {
             if (isNumber(number)){
                 return number.toInt()
             }else{
                 return 0
             }
        }

    }
}